package com.example.blog.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.blog.entity.Follow;
import com.example.blog.mapper.FollowMapper;
import com.example.blog.service.IFollowService;
import com.github.yulichang.query.MPJLambdaQueryWrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
* @author Ading
* @description 针对表【follow】的数据库操作Service实现
* @createDate 2023-07-10 20:33:41
*/
@Service
public class FollowServiceImpl extends ServiceImpl<FollowMapper, Follow>
    implements IFollowService {


    @Resource
    FollowMapper followMapper;

    public void select(String name,int id){
        MPJLambdaQueryWrapper<Follow> wrapper = new MPJLambdaQueryWrapper<Follow>()
                .select(Follow::getStatus)
                .exists(" SELECT DISTINCT u.id\n" +
                        "    FROM USER u\n" +
                        "    LEFT JOIN article a ON a.author = u.NAME\n" +
                        "    WHERE a.author = " + name)
                .and(i -> i.eq(Follow::getUserId, id));
    }
}




